package com.lph.service;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lph.dao.RoleDaoI;
import com.lph.model.Menu;
import com.lph.model.Msg;
import com.lph.model.Role;
import com.lph.model.RoleMenu;
import com.lph.util.MenuUtil;
@Service
public class RoleService implements BaseServiceI<Role>{
	
	@Autowired
	private RoleDaoI rdi;
	public List<Role> find(Role t) {
		List<Role> list=rdi.find(t);
		return list;
	}
	
	public String findRoleMenuRid(Integer rid){
		List<Menu> list =rdi.findRoleMenuRid(rid);
		String menuStr=MenuUtil.createMenu(list);
		return menuStr;
		
	}
	
	public Msg grant(String rid,String mids){
		Msg m=new Msg("授权失败",false);
		String ids[]=mids.split(",");
		List<String> list=new ArrayList<String>();
		list=Arrays.asList(ids);
		int i=rdi.grant(rid,list);
		if(i>0){
			m=new Msg("成功授权", true);
		}
		return m;
		
	}
	public List<RoleMenu> findRoleMenu(RoleMenu r){
		return rdi.findRoleMenu(r);
		
		
	}

	public Role get(Role t) {
		// TODO Auto-generated method stub
		return null;
	}

	public Msg insert(Role t) {
		// TODO Auto-generated method stub
		return null;
	}

	public Msg batchInsert(String objs) {
		// TODO Auto-generated method stub
		return null;
	}

	public Msg edit(Role t) {
		// TODO Auto-generated method stub
		return null;
	}

	public Msg remove(Integer id) {
		// TODO Auto-generated method stub
		return null;
	}

	public Msg batchRemove(String ids) {
		// TODO Auto-generated method stub
		return null;
	}

}
